class Solution:
    def canPlaceFlowers(self, f, n):
        """
        :type flowerbed: List[int]
        :type n: int
        :rtype: bool
        """
        s = len(f)
        if s == 0:
            return 0
        f.insert(0, 0)
        f.append(0)
        for i in range(1, len(f) - 1):
            if f[i] == 0 and f[i - 1] == 0 and f[i + 1] == 0:
                f[i] = 1
                n -= 1
        return n <= 0
